<template>
	<view class="app">
		<image src="../../../static/img/back.png" mode="" @click="backUrl" class="backImge"></image>
		<!-- logo -->
		<view class="logo">
			<image src="../../../static/img/register/logo.png" mode=""></image>
		</view>
		<!-- 登录 -->
		<view class="conteng">
			<view class="loginTip">修改密码</view>
			<view class="loginInput">
				<view class="InputText">
					<input type="text" v-model="currentPassWord" value="" placeholder-class="grayColor" placeholder="请输入当前密码" />
				</view>
				<view class="InputText">
					<input type="password" v-model="Onepassword" value="" placeholder-class="grayColor" placeholder="请输入新密码" />
				</view>
				<view class="InputText">
					<input type="password" v-model="Twopassword" value="" placeholder-class="grayColor" placeholder="请再次输入新密码" />
				</view>
			</view>
			<button class="registerButton" type="default" @tap="goidentity">确定</button>
		</view>
		<!-- <view class="goregister">
			<text></text>
			<text @click="backUrl">取消</text>
		</view> -->
	</view>
</template>

<script scoped>
	import login from "@/serve/api/login.js";
	import toMaintain from "@/serve/api/toMaintain.js"
	import {mapMutations} from "vuex"
	export default {
		data() {
			return {
				currentPassWord: "",
				Onepassword: "",
				Twopassword: "",
			}
		},
		onLoad() {

		},
		methods: {
			...mapMutations(['logout']),
			async goidentity() {
				if (this.isEmpty(this.currentPassWord)) {
					this.tip("请输入当前密码")
					return
				} else if (this.isEmpty(this.Onepassword) || this.Onepassword.length < 6 || this.Onepassword.length > 20) {
					this.tip("请输入6 ~ 20位新密码")
					return
				} else if (this.isEmpty(this.Twopassword)) {
					this.tip("请再次输入新密码")
					return
				}else if (this.Onepassword !== this.Twopassword){
					this.tip("两次密码不一致")
					return
				}
				const res = await login.resetPwd({
					oldPassword: this.currentPassWord,
					newPassword: this.Twopassword,
				});
				if (res) {
					this.logout();
					// uni.switchTab({
					// 	url: "/pages/tabbar/mine/mine"
					// })
					// this.navRouter("/pages/register/login/login")
				}
			},
		}
	}
</script>

<style scoped>
	@import url("@/static/css/login.css");
	.InputText input{
		margin-left: 0;
	}
	.goregister{
		margin-top: 40rpx;
	}
</style>
